#ifndef TDBINTERFACE_H
#define TDBINTERFACE_H

#include "TriCardCommon.h"
#include "TriCardDefs.h"

class TrackSQL;
struct TInfo;
class ThreeCardPokerServer;
class ThreeCardConnection;
class TGame;


//**********************************************************************************************************
//
//  This class serves to define the interface used by the CPokerConnection to talk to objects 
//  that implement game specific database code (e.g., CHoldemSQL and CStudSQL).  
//
//  Additionally, some common logic which is database related, but isn't game specific also 
//  lives in this class.
//
//  There'll be an instance of a class derived from this for every player session on this poker server.
//
//  kharmon.  01-30-06.  #5862.
// 
//**********************************************************************************************************

class TDBInterface
{
public:

    TDBInterface(TrackSQL *pTracker, TInfo *pInfo);    

    virtual ~TDBInterface() { }

    // called everytime a new game is begun.
	virtual bool8 trackNewGame(int32 nBet, int32 nSideBet, uint8 nAntePayTable, 
                               int8 nSidePayTable, int32 compFactor, int32* Balance) = 0;

    // called when the user requests that cards be dealt, usually right after trackNewGame.
    virtual bool8 trackDeal(TGame *pGame) = 0;


    // called when the final status of a game has been determined.
    virtual bool8 trackGameDone(bool8 bRaised, int32 nPayAnte, int32 nPayRaise, int32 nPaySideBet,
					            int32 nOutcome, int32 nBalAdjust, int32 *pnBalance, TGame *pGame) = 0;  // kharmon.  10-17-06.  #8226.

    // called to load any saved game that the current user might have laying around.
	virtual bool8 trackHasSavedGame(ThreeCardConnection *pConn, TGame ** ppGame, int32 * err) = 0;

    // called to (theoretically) save the game state to the database after the cards are dealt.
	virtual bool8 trackSaveGame(TGame *pGame) = 0;

    // called to load the casino settings for the implementing game
    virtual bool8 trackGetOptions(uint8 *pnAntePayTable, uint8 *pnSidePayTable) = 0;

    // get the current user's balance
	virtual bool8 trackGetBalance(int32 *);

    // change the current user's balance
	virtual int32 trackAdjustBalance(int32);

    // get min/max betting limit info for the indicated game.
	virtual bool8 trackGetPlayerLimits(TriCardGameId eGameId, int32* minBet, 
                                       int32* maxBet, int32* compFactor);    

    // complete the login process for the current player (using the data in the TInfo object).
    virtual bool8 trackValidateLogin();

    // used for error logging purposes
    virtual void trackaddBadPacket(TriCardGameId eGameId, int32 error_reason, 
                                   char MessageType, char *msgbuf, int32 msglen);

protected:

    TrackSQL *m_pTracker;    // provides connections to the database and has other useful abilities.
    TInfo    *m_pInfo;       // info about the current player session

};





#endif